﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;

namespace AutoTestingFramework.Core.Configurations
{
    public class TestDataConfigurationSection : ConfigurationSection
    {
        [ConfigurationProperty("TestDataBase")]
        public TestDataBaseSection TestDataBase { get { return (TestDataBaseSection)base["TestDataBase"]; } }
        [ConfigurationProperty("TestCaseDataCollection")]
        public TestCaseDataCollectionSection TestCaseDataCollection { get { return (TestCaseDataCollectionSection)base["TestCaseDataCollection"]; } }
    }

    public class TestDataBaseSection : ConfigurationElement
    {
        [ConfigurationProperty("TestCaseCategory", IsKey = true, IsRequired = true)]
        public string TestCaseCategory
        {
            get
            {
                return base["TestCaseCategory"].ToString();
            }
            set
            {
                TestCaseCategory = value;
            }
        }
        [ConfigurationProperty("TestCaseDataName", IsRequired = true)]
        public string TestCaseDataName
        {
            get
            {
                return base["TestCaseDataName"].ToString();
            }
            set
            {
                TestCaseDataName = value;
            }
        }
        [ConfigurationProperty("TestCaseDataBasePath", IsRequired = true)]
        public string TestCaseDataBasePath
        {
            get
            {
                return base["TestCaseDataBasePath"].ToString();
            }
            set
            {
                TestCaseDataBasePath = value;
            }
        }
    }
    [ConfigurationCollection(typeof(TestCaseDataSection), AddItemName = "TestCaseData")]
    public class TestCaseDataCollectionSection : ConfigurationElementCollection
    {

        protected override ConfigurationElement CreateNewElement()
        {
            return new TestCaseDataSection();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((TestCaseDataSection)element).Name;
        }

        public TestCaseDataSection this[int index]
        {
            get { return (TestCaseDataSection)base.BaseGet(index); }
        }

        new public TestCaseDataSection this[string name]
        {
            get { return (TestCaseDataSection)base.BaseGet(name); }
        }
    }
    
    public class TestCaseDataSection : ConfigurationElement
    {
        [ConfigurationProperty("Name", IsKey = true, IsRequired = true)]
        public string Name
        {
            get
            {
                return base["Name"].ToString();
            }
            set
            {
                Name = value;
            }
        }
        [ConfigurationProperty("TestCaseDataFileName", IsRequired = true)]
        public string TestCaseDataFileName
        {
            get
            {
                return base["TestCaseDataFileName"].ToString();
            }
            set
            {
                TestCaseDataFileName = value;
            }
        }
        [ConfigurationProperty("ColumnsNameListWithComma", IsRequired = true)]
        public string ColumnsNameListWithComma 
        {
            get
            {
                return base["ColumnsNameListWithComma"].ToString();
            }
            set
            {
                ColumnsNameListWithComma = value;
            }
        }
    }
}
